﻿using Eneta.Portal.Forum.Core.Domain.Entities;
using Eneta.Portal.Forum.Core.Service.Application;
using Microsoft.SharePoint;

namespace Eneta.Portal.Forum.Core.Service.Builders
{
    public class MessageListBuilder : ListBuilder
    {
        // Methods
        public MessageListBuilder()
        {
            listName = "spforums_posts";
        }

        public override void AddFields()
        {
            base.AddFieldToList("TopicID", (SPFieldType)9, true);
            base.AddFieldToList("UserID", (SPFieldType)9, false);
            base.AddFieldToList("Body", (SPFieldType)3, false);
        }

        public override void AddSampleData()
        {
            var message = new Message(1);
            message.Name = "Welcome to your new SharePoint Forum";
            message.UserId = 1;
            message.Body = "<DIV>This is an example post in your SharePoint Forum installation. You may delete this post, this topic and even this forum if you like since everything seems to be working!</DIV>";
            RepositoryRegistry.MessageRepository.Save(message);
        }
    }
}
